$(document).ready(function() {
    $('.search input[type=text]').focus(function(){
				if($(this).val() == 'Search...' ){
					$(this).val('');
				}	
			});
	$('.search input[type=text]').blur(function(){
				if($(this).val() == '' ){
					$(this).val('Search...');
				}
	});
	
	
	// to top   -------------------------------- *
	$('.to-top').click(function(){
		$('html, body').animate({
			scrollTop: $(".inner-content h2").offset().top
		}, 700);
	});
	
	// classes * -----------------------------------------------  *
	$('.calendar-column li, .home-content .news-area .news-block, .inner-content, .side-menu li, .programs-list li, .course-details li, .called-block, .contact-us li, .calendar-wrapper').addClass('clearfix');
	$('.home-content .more, .side-column .calendar-column a.more, .courses-title, .top-links li, .list-links li' ).append('<span class="arrow"></span>');
	$('.courses-title').wrapInner('<span class="course-name"></span>');
	$('.home-content .main-column').prepend('<span class="corner"></span>');
	$('.breadcrumb a:first').prepend('<span class="home_icon"></span>');
	$('.courses-list li').append('<span class="arrow"></span>');
	$('.sitemap li li').prepend( $( "<span class='icon'></span>" ) );
	$('.sitemap li li li').prepend( $( "<span class='icon'></span>" ) );
	$('.not_found li').prepend( $( "<span class='icon'></span>" ) );
	$('table tr:even td').css('background', '#f2f2f2');
	$('.called-block:last-child, .underline-block:last-child').css({'margin-bottom':'60px', 'border-bottom':'0'})
	 
	
	
	// * -----------------------------------------------  *
	$('.nav li:first').hover(function(){
		$('.nav-container .left-corner').toggleClass('menu-hover');
	});
	
	$( ".inner-main-column ul.bullet" ).prev('.text-block').css( "padding-bottom", "0" );
	$( ".inner-main-column .text-block" ).prev('.inner-main-column ul.bullet').css( "margin-bottom", "20px" );
	$( ".inner-main-column .bullet li " ).prepend('<span class="icon"></span>');
	$( ".inner-main-column .bullet li, .top-links li, .list-links li " ).wrapInner( "<div class='text'></div>");

	//$('.inner-main-column div').addClass('text-block clearfix');
	$('.text-block').each(function(index, element) {
        if ($(this).children('img').length > 0 == true  ) {
     		 $(this).wrapInner( "<p></p>");	 
		}
		
    });
	$('.text-block img, .inner-main-column .bullet li span.icon, .top-links li div span.arrow, .list-links li div span.arrow').each(function() {
				$(this).parent().before(this);
	});
	
	
	// slice 
	
	/*$('.main-slider .slider-mask p').each(function() {
		var $this = $(this);
		$this.text( $this.text().slice(0, 200));
		});*/
		
		
		$(function(){
		  $(".main-slider .slider-mask p").each(function(i){
			len=$(this).text().length;
			if(len>200)
			{
			  $(this).text($(this).text().substr(0,200)+'...');
			}
		  });       
		});
		
		
		
		/*$('.home-content .news-area .news-block div p').each(function() {
			var $this = $(this);
			$this.text( $this.text().slice(0, 200));
		});*/
		
		$(function(){
		  $(".home-content .news-area .news-block div p").each(function(i){
			len=$(this).text().length;
			if(len>210)
			{
			  $(this).text($(this).text().substr(0,210)+'...');
			}
		  });       
		});
		
		/*$('.programs-list li .details p').each(function() {
			var $this = $(this);
			$this.text( $this.text().slice(0, 250));
		});*/
		
		
		$(function(){
		  $(".programs-list li .details p").each(function(i){
			len=$(this).text().length;
			if(len>250)
			{
			  $(this).text($(this).text().substr(0,250)+'...');
			}
		  });       
		});
		
		
		
		/*$('.news li p, .search-results li p').each(function() {
			var $this = $(this);
			$this.text( $this.text().slice(0, 250) + '...');
		});*/
		
		$(function(){
		  $(".news li p, .search-results li p").each(function(i){
			len=$(this).text().length;
			if(len>250)
			{
			  $(this).text($(this).text().substr(0,250)+'...');
			}
		  });       
		});
		// 
	
	
	
});

	// sliders * -----------------------------------------------  *

$(window).load(function(){
      $('.main-slider').flexslider({
        animation: "fade",
		slideshow: true,
		directionNav: false,
        start: function(slider){
          $('body').removeClass('loading');
        }
      });
	  
	  var heightAdj = $('.home-content').height();
	$('.home-content .side-column').height(heightAdj);
	$('.home-content .main-column').height(heightAdj);
	
	var innerHight = $('.inner-content').height();
	$('.inner-main-column, .inner-content .side-column').height(innerHight);
	
	var calHeight = $('.calendar-wrapper').height();
	// alert(calHeight);
	$('.calendar-left-side, .calendar-right-side').height(calHeight);
	  
	  
    });
	
/* ================================================
		Calendar & news 
   ================================================ */
$(window).load(function() {
		// top 
        $('.news-block:even p').each(function(index, element) {
            if ( $(this).children('i').length > 0 ) {
				$(this).children('i').css({float: 'right', marginRight: '0', marginLeft: '24px'});
				
		}
		else{
			$(this).children('span').css('width', 'auto');
		}
        });
		
		// bottom 
		$('.news-block:odd p').each(function(index, element) {
			if ( $(this).children('i').length > 0 ) {
				
				$(this).children('span').css({width: '435px'});
		}
		else{
			
			//$('.news-block:odd h4').css({float: 'left', width: 'auto'});
			$(this).children('span').css({width: 'auto'});
		}
		});
		
		$('.news-block p').each(function(){
			var y = $(this).width();
			var x = $(this).children('i').children('img').width()+26;
			$(this).children('.news-block p i + span').width(y-x);
			$(this).children('i').width($(this).children('i').children('img').width()+2);
			
			// console.log("image width" +'\n' + x);
			
			// console.log("paragraph" +'\n' + y);
		});
		
		$('.list-fake span.square').html('&#9642;');
    });